#include "PrecompiledHeaders.h"
#include "TeleportController.h"
#include "Ball.h"

#include "math.h"

TeleportController::TeleportController(Ogre::Vector3 from, Ogre::Vector3 to)
{
    this->from = from;
    direction = to - from;
    time_since_teleport = 0.0;
}

void TeleportController::updateBall(Ogre::Real time)
{
    time_since_teleport += time;
    double scale = cos(time_since_teleport * acos(-1.0) / Constants::TELEPORT_DURATION);
    scale = 1 - ((scale / 2) + 0.5);
    ball->setPosition(from + (direction * scale));
    //ball->setGravity(Ogre::Vector3::ZERO);
}

bool TeleportController::registerBall(Ball *b)
{
    ball = b;
    time_since_teleport = 0.0;
    return true;
}
